from django.db import models
from organization.models import OrganizationModel


# Create student models here.
class DeptChoices(models.TextChoices):
    """ 所属学院枚举类 """
    ZC = 'ZC', '智能制造学院'
    JG = 'JG', '经济管理学院'
    ZF = 'ZF', '政法学院'
    MKS = 'MKS', '马克思学院'
    WEN = 'WEN', '文学院'
    WGY = 'WGY', '外国语学院'
    JSJ = 'JSJ', '数学与计算机科学学院'
    WUC = 'WUC', '应用物理与材料学院'
    TUM = 'TUM', '土木建筑学院'
    SW = 'SW', '生物科技与大健康学院'
    FZ = 'FZ', '纺织材料与工程学院'
    JT = 'JT', '轨道交通学院'
    YS = 'YS', '艺术设计学院'


class StudentModel(models.Model):
    """ 学生类 """
    stu_name = models.CharField('学生名字', max_length=20, unique=True)
    password = models.CharField('密码', max_length=150)
    stu_num = models.CharField('学号', max_length=15, unique=True)
    gender = models.CharField('性别', max_length=4, default='男', null=True, blank=True)
    email = models.EmailField('邮箱', null=True, blank=True, unique=True)
    phone_number = models.CharField('电话', max_length=15, blank=True)
    check_status = models.BooleanField('是否通过注册申请', default=True)
    department = models.CharField(
        verbose_name='学生所属学院',
        max_length=10,
        choices=DeptChoices.choices,
        default=DeptChoices.ZC
    )
    create_time = models.DateTimeField('创建时间', auto_now_add=True)

    class Meta:
        db_table = 'student'
        verbose_name = '学生表'
        verbose_name_plural = verbose_name
        ordering = ['id']

    def __str__(self):
        return self.stu_name


class Subscription(models.Model):
    """
    订阅模型类，用于记录学生与企业之间的关注关系。
    """
    student = models.ForeignKey(StudentModel, on_delete=models.CASCADE, verbose_name='学生')
    organization = models.ForeignKey(OrganizationModel, on_delete=models.CASCADE, verbose_name='企业')

    class Meta:
        verbose_name = "订阅"
        verbose_name_plural = "订阅"
        db_table = 'subscription'
